﻿<#include "include/_meta.html">
<title>管理员列表</title>
</head>
<body>
	<div id="rMenu" style="width:100%;height:100%;float:left;">
		<ul style="height: 600px;" id="treeDemo" class="ztree">
		</ul>
	</div>
<#include "include/_footer.html">

<script type="text/javascript">
	var zNodes ;
	var setting = {
		view: {
		dblClickExpand: false,
		showLine: false,
		selectedMulti: false		
	},
	data: {
		simpleData: {
			enable:true,
			idKey: "id",
			pIdKey: "pId",
			rootPId: ""
		}
	},
	check:{
		enable: true,
		chkStyle: "checkbox",
		chkboxType: { "Y": "p", "N": "s" }
	},
	callback: {
		onClick:zTreeOnCheck,
		onRightClick: zTreeOnRightClick
	}
	};
	function zTreeOnCheck(event, treeId, treeNode) {    
		//获取所有树形节点，	
    	var childNodes = zTree.transformToArray(treeNode);
    	//获取当前点击的节点的ＩＤ
    	var perId = childNodes[0].id;  
    	var perType = childNodes[0].resType;    	
    	//获取父窗口里面的 框架控件的ID ，将其的src 地址进行改变，将里面的内容改变成所点击节点的下属属性。
    	if(perType==3 || perType==1 || perType==999){ 
    		if(perType==3){
    			layer.msg('请在右侧窗口选择权限操作!',{icon: 1,time:1500});
    		}  		
    		return;
    	}
    	var resourceIframe=window.parent.document.getElementById("resourceSelect");    	
    	var src = "/getResSelect?permisid="+perId;
    	resourceIframe.src=src;
    	resourceIframe.reload();
 /*
   		var deptUserIframe=window.parent.document.getElementById("deptUserManager");
   		 var src="<%=contextPath %>/system/organizationManager/sysDept_selectDeptManager.do?deptId="+deptId;
    	//alert(deptUserIframe.src);
   	 	deptUserIframe.src=src;
    	deptUserIframe.reload();
   */
}
function zTreeOnRightClick(event, treeId, treeNode) {
	 zTree.selectNode(treeNode);
	  var childNodes = zTree.transformToArray(treeNode); 
	 checkTreeId = childNodes[0].id;
	 
	 if(checkTreeId == "topDept"){
	    showRMenu("topDept", event.clientX, event.clientY);
	 }else{
	    showRMenu("node", event.clientX, event.clientY);
	 }
	 
}
function showRMenu(type, x, y) {
	 $("#rMenu ul").show();
	 if("topDept" == type){
	    $("#m_add").show();
	     $("#m_del").hide();
	 }else{
	   $("#m_add").show();
	   $("#m_del").show();
	 }
	 x=x-20;
	 y=y-5;
	 rMenu.css({"top":y+"px", "left":x+"px", "visibility":"visible"});
	 $("body").bind("mousedown", onBodyMouseDown);
}
function hideRMenu() {
	 if (rMenu) rMenu.css({"visibility": "hidden"});
	 $("body").unbind("mousedown", onBodyMouseDown);
}
function onBodyMouseDown(event){
 if (!(event.target.id == "rMenu" || $(event.target).parents("#rMenu").length>0)) {
	 rMenu.css({"visibility" : "hidden"});
 }
}
function resetTree() {
  hideRMenu();
  $.fn.zTree.init($("#treeDemo"), setting, zNodes);
}
var zTree, rMenu;

$(function(){  
      $.ajax({
     type: "get",
      url:"/getResToJson",
      dataType:"json",
      async:false,
      success:function(data){
      	zNodes=data;
      }
	});
  $.fn.zTree.init($("#treeDemo"),setting,zNodes);
  zTree = $.fn.zTree.getZTreeObj("treeDemo");
  rMenu = $("#rMenu");
});

</script>
</body>
</html>